Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding TracerProviderSdkOptions and use factories for all options #1901

Closed
wants to merge 1 commit into from

Conversation

ejsmith
Copy link
Contributor

@ejsmith ejsmith commented Mar 12, 2021

Changes

This PR is creating TracerProviderSdkOptions class and making it so that the builder is not forced to new up any instances of processors or instrumentations during the configuration phase. This PR is trying to work towards a solution to be able to add DI features (#894) to the builder and allow instances to be created from a DI container, but without taking any DI dependencies in the core project. It's also trying to create a separation between the builder phase and the runtime phase by not forcing instances of classed to be created during the builder phase.

I am hoping to get feedback and see if this is something that the team is interested in pursuing or not.

  • Changes in public API reviewed

@ejsmith
Copy link
Contributor Author

ejsmith commented Mar 12, 2021

This is also related to #1889

@CodeBlanch
Copy link
Member

@ejsmith I totally get what you are thinking with this, and I tried similar things, but I don't think it really solves anything. We're moving the problem from TracerProviderSdk to an options class. Think about this: What is the difference between builder.AddProcessor(new MyProcessor()) and builder.AddProcessor(() => new MyProcessor())? The latter doesn't really get you any closer to the scenarios we are shooting for. But I could be missing something... could you possibly provide examples of how this pattern solves the 3 "Usage Examples" from #1889?

Another thing... this seems more like leaking the implementation than providing options. Could you bind this new options class to IConfiguration? I feel like options classes should be ~POCOs. But really, they should be options. Like timeouts, extension points, etc.. If we go with this, is the builder really adding any value? We could just move all the extensions onto the options. And then rename the options builder 🤣 I say this all with ❤️ I really appreciate the collaboration on this. Super helpful!

@ejsmith
Copy link
Contributor Author

ejsmith commented Mar 14, 2021

Thanks for the feedback. I wanted to try and keep this PR small. But I can expand it to show how it would work with the hosting package.

Builders in .NET are generally just providing a fluent configuration API around an options object. Generally we are just trying to keep the 2 phases separate and make it so that configuring doesn't force you to construct instances.

@ejsmith ejsmith closed this Mar 23, 2021
@ejsmith ejsmith deleted the AddTraceProviderOptions branch March 23, 2021 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants